package com.datang.petstore.service.impl;

import com.datang.petstore.entity.LoginRecord;
import com.datang.petstore.entity.UserInfo;
import com.datang.petstore.entity.UserInfoExample;
import com.datang.petstore.exception.AcceptResultCodeException;
import com.datang.petstore.generatemapper.LoginRecordMapper;
import com.datang.petstore.generatemapper.UserInfoMapper;
import com.datang.petstore.resultpage.ResultCode;
import com.datang.petstore.service.LoginRecordService;
import com.datang.petstore.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-11-01 13:54
 * @notify 登录记录接口
 * @version 1.0
 */

@Service
public class LoginRecordServiceImpl implements LoginRecordService {

    @Autowired
    private UserService userService;

    @Autowired
    private LoginRecordMapper loginRecordMapper;

    /*
     * @author 顶风少年
     * @date 2019/10/22 16:00
     * @mail dfsn199703132038@foxmail.com
     * @throws
     * @param
     * @param loginRecord
     * @result com.datang.petstore.utils.Result
     * @notify 添加登录记录
     * version 1.0
     */
    @Transactional
    public void addLoginRecord(LoginRecord loginRecord) {
        //根据用户id查询用户
        userService.getUserInfo(loginRecord.getUserId());

        loginRecord.setLoginDate(new Date());
        loginRecordMapper.insert(loginRecord);
    }


}
